<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="temp"></button>
    <script>

        function debounce(fn, delay) {
            var timer;
            var ok = true;
            return function () {
                if (timer) {
                    //有定时器
                    clearInterval(timer)
                    ok = false
                }
                if (ok) {
                    fn.apply(null)
                }
                timer = setTimeout(() => {
                    ok = true
                    timer = null
                }, delay)
            }
        }
        function tttt() {
            console.log('asdljljsdfjlsdj');
        }
        // document.getElementById("temp").onclick = debounce(tttt, 5000)
        temp.onclick = debounce(tttt, 5000)

    </script>
</body>

</html>